package io.kiki.sba.registry.lifecycle.impl;

import io.kiki.sba.registry.lifecycle.LifecycleController;
import io.kiki.sba.registry.lifecycle.LifecycleState;


public class DefaultLifecycleController implements LifecycleController {

    @Override
    public boolean canInitialize(LifecycleState.LifecyclePhase phase) {

        return phase == null || phase.equals(LifecycleState.LifecyclePhase.DISPOSED);
    }

    @Override
    public boolean canStart(LifecycleState.LifecyclePhase phase) {

        return phase != null && (phase.equals(LifecycleState.LifecyclePhase.INITIALIZED) || phase.equals(LifecycleState.LifecyclePhase.STOPPED));
    }

    @Override
    public boolean canStop(LifecycleState.LifecyclePhase phase) {

        return phase != null && (phase.equals(LifecycleState.LifecyclePhase.STARTED));
    }

    @Override
    public boolean canDispose(LifecycleState.LifecyclePhase phase) {

        return phase != null && (phase.equals(LifecycleState.LifecyclePhase.INITIALIZED) || phase.equals(LifecycleState.LifecyclePhase.STOPPED));
    }
}
